package enumdemo;

public enum TextEnum {
    RED(0,"RED"),BLACK(1,"BLACK"),
    WHIRE(2,"WHIRE"),GREEN(3,"GREEN");
    public int ordinal;
    public String color;

    TextEnum(int ordinal, String color) {
        this.ordinal = ordinal;
        this.color = color;
    }

    public static void main(String[] args) {
        TextEnum[]textEnums=TextEnum.values();
        for (int i = 0; i < textEnums.length; i++) {
            System.out.println(textEnums[i]+" "+textEnums[i].ordinal());
        }
        TextEnum textEnums1=TextEnum.valueOf("RED");
        System.out.println(textEnums1);

        System.out.println(RED.compareTo(BLACK));
    }


    public static void main1(String[] args) {
        TextEnum textEnum=RED;
        switch (textEnum){
            case RED :
                System.out.println("RED");
                break;
            case BLACK:
                System.out.println("BLACK");
                break;
            case GREEN:
                System.out.println("GREEN");
                break;
            default:
                System.out.println("无法匹配");
                break;
        }
    }
}
